import { createApp } from 'vue'
import Cookies from 'js-cookie'
import ElementPlus from 'element-plus'
import locale from 'element-plus/es/locale/lang/zh-cn' // 中文语言
import 'element-plus/dist/index.css'
import router from './router'
import App from '@/App.vue'
import '@/assets/styles/index.scss' // global css
import './permission'
import '@/apimock'

// svg图标
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon/index.vue'
import elementIcons from '@/components/SvgIcon/svgicon'

// 注册指令
import plugins from './plugins' // plugins

const app = createApp(App)
app.use(router)
app.use(createPinia())
app.use(ElementPlus, {
  locale: locale,
  // 支持 large、default、small
  size: (Cookies.get('size') as any) || 'default',
})
app.use(elementIcons)
app.use(plugins)
app.component('svg-icon', SvgIcon)
app.config.errorHandler = (err) => {
  /* 处理错误 */
  console.error('全局错误捕获:', err)
}
app.mount('#app')
